import java.util.concurrent.TimeUnit;

public class JoinDemo {

    static class SubThread extends Thread{

        @Override
        public void run() {
            try{
                TimeUnit.SECONDS.sleep(5);
            }catch(InterruptedException e){
            }
            System.out.println("SubThread停止了");
        }
    }

    public static void main(String[] args) throws InterruptedException{
        SubThread t=new SubThread();
        t.start();
        t.join();//t线程运行，t线程运行结束main主线程才运行
        System.out.println("t停止了");
    }
}
